<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>四川省工程建设领域项目信息、信用信息公开维护平台</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/reset.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/main.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/My97DatePicker4/WdatePicker.js"></script>
<script src="<%=request.getContextPath()%>/scripts/jquery-latest.pack.js"></script>
<script src="<%=request.getContextPath()%>/scripts/jquery.form.js"></script>
<script type="text/javascript">
function check(f){
	if (f.account.value == ""){
		alert("必须填写帐号");
		f.account.focus();
		return false;
	}
	if (f.userName.value == ""){
		alert("必须填写姓名");
		f.userName.focus();
		return false;
	}
	if (f.userPwd.value == ""){
		alert("必须填写密码");
		f.userPwd.focus();
		return false;
	}
	var oCode = f.orgCode.value.replace('-','');
	if(oCode.indexOf('-')>0 || oCode.indexOf('_')>0){
		alert('请正确组织机构代码，短横杠"-" 下划线"_" 等字符不必输入');
		return false;
	}
	if (f.orgCode.value.length != 9){
		alert("请输入正确的组织机构代码");
		f.orgCode.focus();
		return false;
	}

	if (f.orgName.value == ""){
		alert("必须填写组织机构名称");
		f.authCode.focus();
		return false;
	}

	if (f.email.value == "" || f.email.value.indexOf('@')<0){
		alert("请正确填写电子邮件地址");
		f.authCode.focus();
		return false;
	}
	
	if (f.responser.value == ""){
		alert("必须填写法人代表");
		f.authCode.focus();
		return false;
	}
	if (f.companyAddr.value == ""){
		alert("必须填写公司地址");
		f.authCode.focus();
		return false;
	}

	if (f.authCode.value == ""){
		alert("必须填写验证码");
		f.authCode.focus();
		return false;
	}

	if (f.contacter.value == ""){
		alert("必须填写联系人");
		f.authCode.focus();
		return false;
	}
	
	if (f.phone.value == ""){
		alert("必须填写联系电话");
		f.authCode.focus();
		return false;
	}
	f.orgCode.value = f.orgCode.value.replace('-','');
}

function checkOrgCode(obj)
{
	if (obj.value != "")
	{
		setTimeout(function(){checkOrgCodeDB(obj);}, 2000);
	}
}
function checkOrgCodeDB(obj)
{
	var options={type:"POST", 
				url:"<%=request.getContextPath()%>/user/orgCodeAuth?orgCode="+obj.value, 
				dataType:"json", success: checkOrgCodeHandle};
	$.ajax(options);
}
function checkOrgCodeHandle(data,status) {
	var obj = document.getElementById("oCd");
	if(status){
		if (data.result == 0){
			obj.innerHTML='<font color="#669933">该组织机构代码可以注册</font>';
		}
		else{
			obj.innerHTML='<font color="#FF9966">该组织机构代码已被注册</font>';
		}
	}
	else{
		obj.innerHTML='<font color="#FFFF00">无法检测组织机构代码</font>';
	}
}

function checkAccount(obj)
{
	if (obj.value != "")
	{
		setTimeout(function(){checkAccountDB(obj);}, 2000);
	}
}
function checkAccountDB(obj)
{
	var options={type:"POST", 
				url:"<%=request.getContextPath()%>/user/accountAuth?account="+obj.value, 
				dataType:"json", success: checkAccountHandle};
	$.ajax(options);
}
function checkAccountHandle(data,status) {
	var obj = document.getElementById("acr");
	if(status){
		if (data.result == 0){
			obj.innerHTML='<font color="#669933">本帐号可以使用</font>';
		}
		else{
			obj.innerHTML='<font color="#FF9966">本帐号已存在</font>';
		}
	}
	else{
		obj.innerHTML='<font color="#FFFF00">无法检测帐号</font>';
	}
}
</script>
</head>
<body>
<form method="post" action="<%=request.getContextPath()%>/user/registerAuth" onsubmit="return check(this);">

<table class="top">
  <tr>
    <td width="40" class="topl"></td>
    <td width="840"><div class="plat_title"></div></td>
    <td width="21"><a href="#" class="top_drop_btn"></a></td>
    <td width="20"><a href="#" class="maxbtn"></a></td>
    <td width="29"><a href="#" class="closebtn"></a></td>
  </tr>
</table>
<table class="content">
  <tr>
    <td class="main_l"></td>
    <td class="main_lbar"></td>
    <td width="918" valign="top">
	<div class="banner"><img src="<%=request.getContextPath()%>/images/banner.jpg" /></div>
	<div class="op_con">
    <table class="regtable">
  <tr>
<th colspan="2">用户注册</th>
  </tr>
  <tr>
  <td class="w02"></td>
  <td><span style="padding-right:140px">带<b>*</b>的项为必填项</span></td>
  </tr>
  <tr>
    <td class="w02">帐号</td>
    <td><input type="text" class="intt"  name="account" onblur="checkAccount(this)"/><b>*</b><span id="acr">用于登录的用户名</span></td>
  </tr>
  <tr>
    <td class="w02">姓名</td>
    <td><input type="text" class="intt" name="userName"/><b>*</b><span>账户使用者的姓名</span></td>
  </tr>
  <tr>
    <td class="w02">初始密码</td>
    <td><input type="text" class="intt" name="userPwd"/><b>*</b><span>用于登录的密码，请区分大小写</span></td>
  </tr>
  <tr>
    <td class="w02">组织机构代码</td>
    <td><input type="text" class="intt" name="orgCode" maxlength="9" onblur="checkOrgCode(this)"/><b>*</b><span id="oCd">请输入9位有效数字或字母</span></td>
  </tr>
  <tr>
    <td class="w02">组织机构名称</td>
    <td><input type="text" class="intt" name="orgName"  maxlength="50"/><b>*</b><span>请输入组织结构的全称</span></td>
  </tr>
  <tr>
    <td class="w02">成立时间</td>
    <td><input type="text" class="intt" name="estDate"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td>
  </tr>
  <tr>
    <td class="w02">法人代表</td>
    <td><input type="text" class="intt" name="responser" maxlength="50"/><b>*</b></td>
  </tr>
  <tr>
    <td class="w02">地址</td>
    <td><input type="text" class="intt" name="companyAddr" maxlength="50"/><b>*</b></td>
  </tr>
  <tr>
    <td class="w02">联系人</td>
    <td><input type="text" class="intt" name="contacter" maxlength="50"/><b>*</b><span>敏感信息将不会被公开</span></td>
  </tr>
  <tr>
    <td class="w02">联系电话</td>
    <td><input type="text" class="intt" name="phone" maxlength="50"/><b>*</b><span>敏感信息将不会被公开</span></td>
  </tr>
  <tr>
    <td class="w02">电子邮件</td>
    <td><input type="text" class="intt" name="email" maxlength="50"/><b>*</b><span>找回密码必填</span></td>
  </tr>
  <tr>
    <td class="w02">验证码</td>
    <td><input type="text" class="intt" name="authCode" style="width:130px;" maxlength="4"/>
    <img style="cursor: hand;" id="authImage"
		 src="<%=request.getContextPath()%>/servlet/auth/image.jpg"
		 onclick="this.src='<%=request.getContextPath()%>/servlet/auth/image.jpg?'+Math.random();"
		 alt="点击换一张" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" value="注册" class="btn40" />
    <input style="margin:0 0 0 5px;" type="button" value="登录" class="btn40" onclick="location.href='login.jsp';return false;"/></td>
  </tr>
    <tr>
  <td colspan="2"></td>
  </tr>
</table>

	</div>
	</td>
    <td class="main_rbar"></td>
	<td class="main_r"></td>
  </tr>
</table>
</form>
<table class="bot">
	<tr>
		<td width="41"><div class="botl"></div></td>
		<td width="867"></td>
		<td width="42"><div class="exit"></div></td>
	</tr>
</table>
<c:import url="/foot.jsp" />
</body>
</html>
